#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
    string reverseParentheses(string s) {
        stack<char> strStack;
        for (auto ch:s) {
            if (ch != ')') {
                strStack.push(ch);
            } else {
                string popString;
                while (true) {
                    auto top = strStack.top();
                    strStack.pop();
                    if (top != '(') {
                        popString.push_back(top);
                    } else {
                        for (auto popCh:popString) {
                            strStack.push(popCh);
                        }
                        break;
                    }
                }
            }
        }
        string ans;
        while (!strStack.empty()) {
            ans.push_back(strStack.top());
            strStack.pop();
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
};

int main() {
    Solution solution;
    string s;
    while (cin >> s)
        cout << solution.reverseParentheses(s) << endl;
}